﻿using System.Data.Entity.ModelConfiguration;
using yiCommerce.Core.Domain.Shops;
using yiCommerce.Core.Domain.Statuses;

namespace yiCommerce.Data.Mapping.Statuses
{
    public class StatusesMapping : EntityTypeConfiguration<Status>
    {

        public StatusesMapping()
        {
            this.ToTable("Statuses");
            this.HasKey(c => c.Id);

            this.HasMany(b => b.Comments)
                .WithRequired(p => p.Status);

            this.HasRequired(b => b.Customer)
                .WithMany()
                .HasForeignKey(b => b.CustomerId);

            this.HasOptional(b => b.Product)
          .WithMany()
          .HasForeignKey(b => b.ProductId).WillCascadeOnDelete(false);
        }
    }
}